<?php if (!defined('THINK_PATH')) exit(); /*a:1:{s:88:"/data/www/html/web2017/public_html/../application/index/view/usercenter/gongwen_add.html";i:1498806450;}*/ ?>
<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no">
    <title>发表话题</title>
    <!-- 最新版本的 Bootstrap 核心 CSS 文件 -->
    <!--<link rel="stylesheet" href="https://cdn.bootcss.com/bootstrap/3.3.7/css/bootstrap.min.css" integrity="sha384-BVYiiSIFeK1dGmJRAkycuHAHRg32OmUcww7on3RYdg4Va+PmSTsz/K68vbdEjh4u" crossorigin="anonymous">-->
    <link rel="stylesheet" href="__STATIC__/style/weui.min.css">
    <link rel="stylesheet" href="__STATIC__/style/cmgd.css">
    <script src="/static/admin/js/jquery.min.js?v=2.1.4"></script>
    <script src="/static/admin/js/jquery.form.js"></script>
    <script src="/static/admin/js/plugins/layer/laydate/laydate.js"></script>
    <script src="/static/pc/js/layer/layer.js"></script>
    <script src="/static/admin/js/laypage/laypage.js"></script>
    <script src="/static/admin/js/laytpl/laytpl.js"></script>
    <!--奥森图标-->
    <link rel="stylesheet" href="__STATIC__/style/FontAwesome_4.2.0/css/font-awesome.min.css">
    <style>
        .text{padding-left:9px; }
        .weui-uploader__input-box{margin-left: 10px;}
        .fa-list-ul{padding-right:8px;}
        .red{color:red;}
        .weui-btn_primary{width:90%;}
    </style>
</head>
<body>

<div class="container" id="container">

    <!--顶部搜索-->
    <div class="page home js_show">

        <form id="form" action="<?php echo url('gongwen_add'); ?>" enctype="multipart/form-data" method="post">


            <div class="weui-cells__title">收文方  </div>
            <div class="weui-cells">
                <div class="weui-cell weui-cell_select">
                    <div class="weui-cell__bd">
                        <select class="weui-select" name="shou_id" id="shou_id">
                                  <option  value="">请选择</option>
                            <?php if(is_array($instits) || $instits instanceof \think\Collection || $instits instanceof \think\Paginator): if( count($instits)==0 ) : echo "" ;else: foreach($instits as $key=>$val): ?>
                                  <option  value="<?php echo $val['id']; ?>"  ><?php echo $val['name']; ?></option>
                            <?php endforeach; endif; else: echo "" ;endif; ?>
                        </select>
                    </div>
                </div>
            </div>

            <div class="page__bd" style="height: 100%;">
                <div class="weui-cells__title">标题</div>
                <div class="weui-cells">
                    <div class="weui-cell">
                        <div class="weui-cell__bd">
                            <input class="weui-input" name="title" id="title" type="text" placeholder="请输入标题" value="">
                        </div>
                    </div>
                </div>


                <div class="weui-cells__title">内容</div>
                <div class="weui-cells weui-cells_form">
                    <div class="weui-cell">
                        <div class="weui-cell__bd">
                            <textarea class="weui-textarea" name="content"  id="content" placeholder="请输入内容 " rows="10"></textarea>
                        </div>
                    </div>
                </div>

                <div style="position: fixed;bottom:0px;width: 100%;">
                <button class="weui-btn weui-btn_primary" type="submit" id="fabu" > 发布 </button>
                </div>

            </div>
        </form>
    </div>
</div>
</body>
<script type="text/javascript" src="/static/admin/webupload/webuploader.min.js"></script>
<script type="text/javascript">


    $(function(){
        $('#form').ajaxForm({
            beforeSubmit: checkForm, // 此方法主要是提交前执行的方法，根据需要设置
            success: complete, // 这是提交后的方法
            dataType: 'json'
        });

        function checkForm(){

            var title =   $('#title').val();
            var content =   $('#content').val();
            var shou_id =   $('#shou_id').val();

            if(title==''){
                layer.msg('标题不能为空',{icon:5,time:1000,shade: 0.1,});
                return false;
            }

            if(shou_id==''){
                            layer.msg('收文方不能为空',{icon:5,time:1000,shade: 0.1,});
                            return false;
                        }


            if(content==''){
                layer.msg('内容不能为空',{icon:5,time:1000,shade: 0.1,});
                return false;
            }





        }

        function complete(data){
            if(data.code == 1){
                layer.msg(data.msg, {icon: 6,time:1500,shade: 0.1}, function(index){
                    layer.close(index);
                    window.location.href="<?php echo url('Usercenter/gongwen'); ?>";
                });
            }else{
                layer.msg(data.msg, {icon: 5,time:1500,shade: 0.1}, function(index){
                    layer.close(index);
                });
                return false;
            }
        }

    });







</script>

</html>